import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SkillInfo } from "../../../model/SkillInfo";
import { SkillConst } from "../SkillConst";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
//class SkillBaseInfoRender
    
    export  class SkillBaseInfoRender /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._name = new Object /* flash.text.TextField */();
            this._name.textColor = 16580298;
            this._name.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._name.selectable = false;
            addChild(this._name);
            this._info = new Object /* flash.text.TextField */();
            this._info.textColor = 11661311;
            this._info.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._info.selectable = false;
            this._info.multiline = true;
            this._info.wordWrap = true;
            this._info.width = 210;
            this._info.y = 20;
            addChild(this._info);
            this._opt = new Object /* flash.text.TextField */();
            this._opt.x = 130;
            this._opt.textColor = 16580298;
            this._opt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._opt.selectable = false;
            this._opt.addEventListener(flash.events.TextEvent.LINK, this.onOptTextLickHandler);
            addChild(this._opt);
            return;
        }

        /* internal  */onOptTextLickHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SkillBaseInfoShow, this._skill));
            return;
        }

        public updateData(arg1: SkillInfo): void
        {
            this._skill = arg1;
            this._name.text = this._skill.tSkill.skillName;
            this._info.text = this._skill.tSkill.skillDescription;
            if (arg1.skillId != SkillConst.Ore) 
            {
                if (this._opt.parent) 
                {
                    this._opt.parent.removeChild(this._opt);
                }
            }
            else 
            {
                this._opt.htmlText = "<u><a href=\'event: 0\'>" + HTMLUtil.addColor(Language.getString(22007), "#00ff00") + "</a></u>";
                if (!this._opt.parent) 
                {
                    addChild(this._opt);
                }
            }
            return;
        }

        public get skill(): SkillInfo
        {
            return this._skill;
        }

        public /* override */ get height(): number
        {
            return this._name.textHeight + this._info.textHeight + 4;
        }

        protected /* var */_skill: SkillInfo;

        protected /* var */_name: Object /* flash.text.TextField */;

        protected /* var */_info: Object /* flash.text.TextField */;

        protected /* var */_opt: Object /* flash.text.TextField */;
    }
